const service = require('../service/pushcontent')
class Pushcontent{
    async create(ctx, next){
        //创建文章 
        console.log("开始创建文章");
        console.log(ctx.request.body);
        const {valueHtml,title,type,id,reward} = ctx.request.body
        console.log(valueHtml, title,type,id,reward);
        ctx.body = await service.create(valueHtml,title,type,id,reward)
        
    }
    async gettext(ctx, next) {
        //获得文章
        const {l,m} =ctx.query
        const data = await service.gettext(l,m)
        console.log(l,m);
        console.log(data);
        ctx.body =data
    }
    async putarticle(ctx, next){
        const {aid ,userid} = ctx.query
        console.log(aid , userid);
        ctx.body = await service.putarticle(aid,userid)

    }
    async textdelete(ctx,next){
        //删除文章 
        const  {user_id, id} = ctx.request.body
        ctx.body = await service.textdelete(user_id, id)
    }
    async articlereply(ctx,next) {
        console.log(ctx.request.body);
        const {valueHtml,articleid,id} = ctx.request.body
        console.log(valueHtml,articleid,id);
        ctx.body = await service.articlereply(valueHtml,articleid,id)
    }
    async getarticlereply(ctx,next){
        const {articleid,l,m} = ctx.query
        console.log( articleid,l,m);
        ctx.body = await service.getarticlereply(articleid,l,m)
    }
    async getallarticlereply(ctx,next) {
        const {articleid} = ctx.query 
        console.log(articleid,'用户id ');
        ctx.body = await service.getallarticlereply(articleid)
    }
    //获取文章评论 

    async getcomment(ctx,next) {
        const {articleid} = ctx.query
        console.log(articleid);
        ctx.body = await service.getcomment(articleid)
    }
    // 添加文章评论
    async setcomment(ctx,next){
        const {commentid, userid, zzycomment, articleid} = ctx.request.body
        console.log(commentid, userid, zzycomment, articleid);
        ctx.body = await service.setcomment(commentid, userid, zzycomment, articleid)


    }
}

module.exports = new Pushcontent()